package com.dayangxiaoen.pms.handler;


import com.dayangxiaoen.pms.enums.StatusCode;
import com.dayangxiaoen.pms.vo.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author dayangxiaoen
 */

//对加了ControllerAdvice 注解的方法进行拦截
@ControllerAdvice
@ResponseBody
public class AllExceptionHandler {

    //对异常进行处理
    @ExceptionHandler(Exception.class)
    public Result doException(Exception ex){
        ex.printStackTrace();
        return Result.fail(StatusCode.SERVER_ERROR);
    }

}
